package com.yidian.controller.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yidian.pojo.order.CategoryReport;
import com.yidian.server.order.CategoryReportService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * @author whb
 * @create 2021-06-02 16:15
 * @desciption 商品类目统计控制类
 */
@RestController
@RequestMapping("/categoryReport")
public class CategoryReportController {
    @Reference
    private CategoryReportService categoryReportService;

    /**
     * 昨天的数据统计（商品类目）
     * @return
     */
    @GetMapping("/yesterday")
    public List<CategoryReport> yesterday(){
        //LocalDate yesterdayDate=LocalDate.now().minusDays(1); //得到昨天的日期
        LocalDate yesterdayDate=LocalDate.of(2019,4,15);
        return categoryReportService.categoryReport(yesterdayDate);
    }

    /**
     * 按日期统计（商品一级类目）
     * @param beginDate
     * @param endDate
     * @return
     */
    @GetMapping("/category1Count")
    public List<Map> category1Count(String beginDate,String endDate){
        return categoryReportService.categoryId1Count(beginDate,endDate);
    }
}
